
module.exports = {
	query: function (param) {
		var sql="select price-goods_coupons as cprice,t.shopping_password,t.id,t.goods_id,t.goods_title,t.pict_url,t.price,t.coupons_promote_url,t.month_sales,t.goods_coupons from tb_goods_conver t where goods_coupons!=0 and shopping_password!='0' and price-goods_coupons>0 "
		if(param.kw){
			sql=sql+"and goods_title like CONCAT('%','"+param.kw+"','%') ";
		}
		if(param.id){
			sql=sql+"and id= "+param.id;
		}

		if(param.node){
			if(param.node==1001){
				sql=sql+"and price-goods_coupons<9.9";
			}else if(param.node==1002){
				sql=sql+"and month_sales>1000";
			}else if(param.node==1003){
				sql=sql+"and 	goods_lables=1";
			}else if(param.node==1004){
				sql=sql+"and node=12";
			}else
				sql=sql+"and node="+param.node;
		}
		if(param.px){
			if(param.px==1)
				sql=sql+' ORDER BY goods_coupons desc '
			if(param.px==2)
				sql=sql+' ORDER BY start_time desc '
			if(param.px==3)
				sql=sql+' ORDER BY month_sales desc '
			if(param.px==4)
				sql=sql+' ORDER BY price-goods_coupons '
		}else
			sql=sql+' ORDER BY goods_coupons '
		var pageNo=1;
		var pageSize=10;
		if(param.pageNo){
			pageNo=param.pageNo;
		}
		if(param.pageSize){
			pageSize=param.pageSize;
		}
		var start=(pageNo-1)*pageSize
		var offset=pageSize;
		sql=sql+' limit '+start+','+offset;
		console.log(sql);
		return sql;
	}
};